#include <cstdio>
#include <queue>
const int mod = 998244353;
long long n;
int q;
inline long long qpow(long long base, long long exp) {
	long long res = 1;
	while (exp) {
		if (exp & 1) res = res * base % mod;
		base = base * base % mod;
		exp >>= 1;
	}
	return res;
}
int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
	freopen("map.in", "r", stdin);
	freopen("map.out", "w", stdout);
#endif
#endif

	scanf("%lld%d", &n, &q);
	long long t = 0;
	if (n == 2) {
		while (q--) {
			scanf("%lld", &t);
			printf((t & 1) ? "0\n" : "1\n");
		}
		return 0;
	}
	while (q--) {
		scanf("%lld", &t);
		if (t == 0)
			printf("1\n");
		else
			printf("%lld\n", qpow(qpow(n - 1, mod - 2), t - 1) % mod);
	}
	return 0;
}